home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Nebula 2
/
Nebula Two.iso
/
SourceCode
/
Palettes
/
TablePrinter
/
TablePrinter.m
< prev
next >
Wrap
Text File
|
1995-06-12
|
6KB
|
270 lines
// TablePrinter -- A cover class for DBTableViewPrinter.
//
// By Eric T. Seymour, NeXT Computer, Inc.
//
// This object creates and maintains an instance of DBTableViewPrinter in
// an off screen window. This was designed primarily for ease of use in IB.
//
// You may freely copy, distribute, and reuse the code in this example.
// NeXT disclaims any warranty of any kind, expressed or implied, as to its
// fitness for any particular use.
//
// This file looks best when using tabstops of 3.
#import "TablePrinter.h"
#import "DBTableViewPrinter.h"
@implementation TablePrinter
// return the image for the instance icon in the IB file
- (NXImage *)getIBImage
{
char path[MAXPATHLEN + 1];
[[NXBundle bundleForClass:[self class]] getPath:path
forResource:"TablePrinter" ofType:"tiff"];
return [[NXImage alloc] initFromFile:path];
}
- init
{
id theWindow,
theScrollView;
NXRect frm = {100.0,100.0,200.0,200.0};
// init things
[super init];
tableView = nil;
// Create a hidden window
theWindow = [[Window alloc] initContent:&frm
style:NX_TITLEDSTYLE
backing:NX_BUFFERED
buttonMask:NX_CLOSEBUTTONMASK
defer:NO];
// Create a scrollview and place inside the window
NXSetRect(&frm,0.0,0.0,190.0,190.0);
theScrollView = [[ScrollView alloc] initFrame:&frm];
[theScrollView setHorizScrollerRequired:YES];
[theScrollView setVertScrollerRequired:YES];
[theWindow setContentView:theScrollView];
// Create a printerView and place it in the scrollView
printerView = [[DBTableViewPrinter alloc] initFrame:&frm];
[theScrollView setDocView:printerView];
return self;
}
- copyFromZone:(NXZone *)zone
{
// Copy self
self = [super copyFromZone:zone];
[self awake];
return self;
}
- awake
{
id theWindow,
theScrollView;
NXRect frm = {100.0,100.0,200.0,200.0};
[super awake];
// Create a hidden window
theWindow = [[Window alloc] initContent:&frm
style:NX_TITLEDSTYLE
backing:NX_BUFFERED
buttonMask:NX_CLOSEBUTTONMASK
defer:NO];
// Create a scrollview and place inside the window
NXSetRect(&frm,0.0,0.0,190.0,190.0);
theScrollView = [[ScrollView alloc] initFrame:&frm];
[theScrollView setHorizScrollerRequired:YES];
[theScrollView setVertScrollerRequired:YES];
[theWindow setContentView:theScrollView];
// Place the TablePrinter inside the ScrollView
[theScrollView setDocView:printerView];
[theWindow display];
return self;
}
- free
{
// free my hidden window, which in turn frees all its contents
[[printerView window] free];
return [super free];
}
- setTableView:table
{
tableView = table;
return self;
}
- tableView{return tableView;}
// return the actual DBTablePrinterView
- printerView{return printerView;}
- printPSCode:sender
{
// Set the table and print
[printerView setTableView:tableView];
return [printerView printPSCode:sender];
}
- read:(NXTypedStream*)stream
{
[super read:stream];
printerView = NXReadObject(stream);
NXReadTypes(stream,"@",&tableView);
return self;
}
- write:(NXTypedStream*)stream
{
[super write:stream];
NXWriteObject(stream,printerView);
NXWriteTypes(stream,"@",&tableView);
return self;
}
- (const char *)getInspectorClassName
{
return "TablePrinterInspector";
}
// DBTableViewPrinter Cover Methods. These are designed to respond to UI
// target/action events. For example, "forceColorToggle:" could be the
// target of a toggle button. After being messaged, "forceColorToggle" would
// then query the state of that toggle button (sender) and set the value
// directly in the printerView.
- headerBezelToggle:sender
{
if ( sender && [sender respondsTo:@selector(state)] )
[printerView setColumnHeadersBezeled:[sender state]];
return self;
}
- forceColorToggle:sender
{
if ( sender && [sender respondsTo:@selector(state)] )
[printerView setForceDrawColor:[sender state]];
return self;
}
- pageNumbersToggle:sender
{
if ( sender && [sender respondsTo:@selector(state)] )
[printerView setPageNumbersEnabled:[sender state]];
return self;
}
- rowNumbersToggle:sender
{
if ( sender && [sender respondsTo:@selector(state)] )
[printerView setRowNumbersEnabled:[sender state]];
return self;
}
- gridLinesToggle:sender
{
if ( sender && [sender respondsTo:@selector(state)] )
[printerView setGridLinesOn:[sender state]];
return self;
}
- selectedRowsToggle:sender
{
if ( sender && [sender respondsTo:@selector(state)] )
[printerView setSelectedRowsOnly:[sender state]];
return self;
}
- startPageNum:sender
{
if ( sender && [sender respondsTo:@selector(intValue)] )
[printerView setStartingPageNumber:[sender intValue]];
return self;
}
- startRowNum:sender
{
if ( sender && [sender respondsTo:@selector(intValue)] )
[printerView setStartingRowNumber:[sender intValue]];
return self;
}
- pageNumSeparator:sender
{
if ( sender && [sender respondsTo:@selector(stringValue)] )
[printerView setPageNumberSeparator:[sender stringValue][0]];
return self;
}
- rowNumHeader:sender
{
if ( sender && [sender respondsTo:@selector(stringValue)] )
[printerView setRowNumbersTitle:[sender stringValue]];
return self;
}
- headerTextColor:sender
{
if ( sender && [sender respondsTo:@selector(color)] )
[printerView setColumnHeadersTextColor:[sender color]];
return self;
}
- headerBackColor:sender
{
if ( sender && [sender respondsTo:@selector(color)] )
[printerView setColumnHeadersBackColor:[sender color]];
return self;
}
- rowNumTextColor:sender
{
if ( sender && [sender respondsTo:@selector(color)] )
[printerView setRowNumbersTextColor:[sender color]];
return self;
}
- rowNumBackColor:sender
{
if ( sender && [sender respondsTo:@selector(color)] )
[printerView setRowNumbersBackColor:[sender color]];
return self;
}
- gridColor:sender
{
if ( sender && [sender respondsTo:@selector(color)] )
[printerView setGridLinesColor:[sender color]];
return self;
}
- pageNumColor:sender
{
if ( sender && [sender respondsTo:@selector(color)] )
[printerView setPageNumberColor:[sender color]];
return self;
}
- backgroundColor:sender
{
if ( sender && [sender respondsTo:@selector(color)] )
[printerView setBackgroundColor:[sender color]];
return self;
}
@end